<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
 <head>
  <title>inputEx - Form Usage</title>

<!-- YUI CSS -->
<link rel="stylesheet" type="text/css" href="../lib/yui/reset/reset-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/fonts/fonts-min.css">
<link rel="stylesheet" type="text/css" href="../lib/yui/container/assets/container.css"> 
<link rel="stylesheet" type="text/css" href="../lib/yui/assets/skins/sam/skin.css">

<!-- InputEx CSS -->
<link type='text/css' rel='stylesheet' href='../css/inputEx.css' />

<!--[if IE 6]>
<link type='text/css' rel='stylesheet' href='../css/inputEx-IE6.css' />
<![endif]-->

<!-- Demo CSS -->
<link rel="stylesheet" type="text/css" href="css/demo.css"/>
<link rel="stylesheet" type="text/css" href="css/dpSyntaxHighlighter.css">
<style>
div.inputEx-Form-Mask div { background-color:#DDDDFF; }
div#container3 { width:400px }
</style>
 </head>

 <body>

<p class='demoTitle'>inputEx - Form Usage</p>


<!-- Example 1 -->
<div class='exampleDiv'>

	<p class="title">Basic Form creation</p>
	
	<p>Use the following code to create a basic inputEx Form.</p>

	<div class='demoContainer' id='container1'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			new YAHOO.inputEx.Form( { 
				fields: [ 
					{type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
					{inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } }, 
					{inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }, 
					{type:'email', inputParams: {label: 'Email', name: 'email'}}, 
					{type:'url', inputParams: {label: 'Website',name:'website'}} 
				], 
				buttons: [{type: 'submit', value: 'Change'}], 	
				parentEl: 'container1' 
			});
		</textarea>
			</div>

</div>

<!-- Example 2 -->
<div class='exampleDiv'>
	<p class="title">Multi-group Form</p>
	<p>Use the following code to create a Form with multiple Groups (fieldsets).</p>
	<div class='demoContainer' id='container2'></div>
	<div class='codeContainer'>
    <textarea name="code" class="JScript">
	   new YAHOO.inputEx.Form( {
	        fields: [
	            {type:'group',inputParams:{legend:'group 1',name:'group1',fields:[
	                {type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
	                {inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } },
	                {inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }
	            ]}},
	            { type:'group',inputParams:{legend:'group 2',name:'group2',fields:[
	                {type:'email', inputParams: {label: 'Email', name: 'email'}},
	                {type:'url', inputParams: {label: 'Website',name:'website'}}
	            ]}}
	        ],
	        buttons: [{type: 'submit', value: 'Change'}],
	        parentEl: 'container2'
	    });
	</textarea>
    </div>
</div>

<!-- Example 3 -->
<div class='exampleDiv'>

	<p class="title">Send with ajax</p>
	
	<p>How to send the form data using Ajax</p>

	<div class='demoContainer' id='container3'></div>

	<div class='codeContainer'>
				<textarea name="code" class="JScript">
			new YAHOO.inputEx.Form( { 
				fields: [ 
					{ type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
					{ inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } }, 
					{ inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }
				], 
				buttons: [{type: 'submit', value: 'Change'}], 	
				parentEl: 'container2',
				ajax: {
					method: 'POST',
					uri: 'default.php',
					callback: {
						success: function(o) { alert("success", o); },
						failure: function(o) { alert("failure", o); }
					},
					showMask:true
				}
			});
		</textarea>
			</div>

</div>


<!-- YUI Library -->
<script type="text/javascript" src="../lib/yui/yahoo/yahoo-min.js"></script> 
<script type="text/javascript" src="../lib/yui/dom/dom-min.js"></script> 
<script type="text/javascript" src="../lib/yui/event/event-min.js"></script>
<script type="text/javascript" src="../lib/yui/container/container-min.js"></script>
<script type="text/javascript" src="../lib/yui/connection/connection-min.js"></script>
<script type="text/javascript" src="../lib/yui/json/json-min.js"></script>

<!-- InputEx -->
<script src="../js/inputex.js"  type='text/javascript'></script>
<script src="../js/Field.js"  type='text/javascript'></script>
<script src="../js/fields/StringField.js"  type='text/javascript'></script>
<script src="../js/fields/EmailField.js"  type='text/javascript'></script>
<script src="../js/fields/UrlField.js"  type='text/javascript'></script>
<script src="../js/fields/SelectField.js"  type='text/javascript'></script>
<script src="../js/Group.js"  type='text/javascript'></script>
<script src="../js/Form.js"  type='text/javascript'></script>

<script>

YAHOO.util.Event.addListener(window, 'load', function() {
	// Required for the UrlField
	YAHOO.inputEx.spacerUrl = "../images/space.gif";

	// Example 1
	new YAHOO.inputEx.Form( { 
		fields: [ 
			{type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
			{inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } }, 
			{inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }, 
			{type:'email', inputParams: {label: 'Email', name: 'email'}}, 
			{type:'url', inputParams: {label: 'Website',name:'website'}} 
		], 
		buttons: [{type: 'submit', value: 'Change'}], 	
		parentEl: 'container1' 
	});

    // Example 2
   new YAHOO.inputEx.Form( {
        fields: [
            {type:'group',inputParams:{legend:'group 1',name:'group1',fields:[
                {type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
                {inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } },
                {inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }
            ]}},
            { type:'group',inputParams:{legend:'group 2',name:'group2',fields:[
                {type:'email', inputParams: {label: 'Email', name: 'email'}},
                {type:'url', inputParams: {label: 'Website',name:'website'}}
            ]}}
        ],
        buttons: [{type: 'submit', value: 'Change'}],
        parentEl: 'container2'
    });


	// Example 3
	new YAHOO.inputEx.Form( {
		fields: [ 
			{ type: 'select', inputParams: {label: 'Title', name: 'title', selectValues: ['Mr','Mrs','Mme'] } },
			{ inputParams: {label: 'Firstname', name: 'firstname', required: true, value:'Jacques' } }, 
			{ inputParams: {label: 'Lastname', name: 'lastname', value:'Dupont' } }
		], 
		buttons: [{type: 'submit', value: 'Change'}], 	
		parentEl: 'container3',
		ajax: {
			method: 'POST',
			uri: 'default.php',
			callback: {
				success: function(o) { alert("success", o); },
				failure: function(o) { alert("failure", o); }
			},
			showMask:true
		}
	});
	
});

</script>

<script src="js/dpSyntaxHighlighter.js"></script>
<script language="javascript"> 
dp.SyntaxHighlighter.HighlightAll('code');
</script>

 </body>
</html>